/*LICENSE_BEGIN
 * ******************************************************************
 * Copyright 2006 by the Dainamite Robocup-Team at the
 * DAI-Labor, TU-Berlin (www.dai-labor.de)
 * 
 * Members of Dainamite are:
 * Holger Endert
 * Robert Wetzker
 * Thomas Karbe
 * Axel Heßler
 * Philippe Bütter
 * Felix Brossmann
 * 
 * Licensed under the GNU GPL (General Public License) Free Software 
 * License, Version 2. You may use this file only in compliance with 
 * the License. You may obtain a copy of the License at:
 * 
 * http://www.fsf.org/licensing/licenses/gpl.txt
 * ******************************************************************
LICENSE_END*/
/* Generated By:JavaCC: Do not edit this line. HearParser.java */
                          // Robocup Message Parser
package robocup.parser9;

import robocup.component.ControllerNumbers.REFEREE_MESSAGE;
import robocup.component.ControllerNumbers.PLAY_MODE;
import robocup.component.speechacts.coachlanguage.TypeConstants.MESSAGETYPE;
import robocup.component.infotypes.PlayerSayInfo;
import robocup.component.infotypes.CoachSayInfo;
import robocup.component.infotypes.RefereeInfo;
import robocup.component.infotypes.PlayModeInfo;
import robocup.component.infotypes.Info;
import robocup.component.infotypes.InitInfo;
import robocup.component.RobocupAgent;
import robocup.component.AbstractAgent;
import java.io.StringReader;


/**
 * The Parser for all hear messages. This class is created by the
 * javacc parser generator. Therefore do not change this class directly,
 * but change the HearParser.jj and regenerate the code afterwards.
 */
public class HearParser implements HearParserConstants {

        /**
	 * The command to parse.
	 */
        String cmd;

        /**
	 * The reference to the agent, which contains the parser.
	 */
        AbstractAgent ra;

        /**
	 * The info, which will be returned by the parser.
	 */
        Info ret = null;

        /**
	 * An info for PlayerSay-Messages.
	 */
        PlayerSayInfo psi;

        /**
	 * An info for PlayMode-Changes.
	 */
        PlayModeInfo pmi;

        /**
	 * An info for referee messages.
	 */
        RefereeInfo  ri;

        /**
	 * An info for initialisation status.
	 */
        InitInfo     ii;

        /**
	 * Clang-Parser for all CLang massages.
	 */
        CLangParser cl;

        /**
	 * An info object.
	 */
        Info info = null;

        /**
	 * Creates a new instance of the parser.
	 * @param - StringReader - reader for accessing strings
	 * @param - AbstractAgent - the agent object containing this parser
	 */
        public HearParser(StringReader str, AbstractAgent ra) {
                this(str);
                this.ra = ra;
                psi  = new PlayerSayInfo(0,0,null);
                pmi  = new PlayModeInfo(0,PLAY_MODE.UNKNOWN);
                ri   = new RefereeInfo(0,REFEREE_MESSAGE.UNKNOWN);
                ii   = new InitInfo(0,0,false, ra.getTeamName());
                cl = new CLangParser(new StringReader(""), ra);
        }


        /**
	 * Method for parsing heared messages of the type:
	 * - PlayerSayMessage
	 * - RefereeMessage
	 * - PlayModeMessage
	 * - Clang-Messages (forwarded to the CLangParser).
	 * @param - the message
	 * @return the corrpesonding info-object.
	 */
        public Info parseHear(String cmd)
        throws ParseException{
        ReInit(new StringReader(cmd));
    this.cmd = cmd;
        ret = null;
    try {
        startHearCommand();
    } catch (ParseException e) {
        System.out.println("Exception during Parsing with Command:");
      System.out.println("  " + cmd +"\r\n"+ e);
      e.printStackTrace();
    }
    return ret;
        }

        /**
	 * Method for parsing heared messages of the type:
	 * - Init-Message
	 * @param - the message
	 * @return the corrpesonding info-object.
	 */
  public Info parseInit(String cmd)
      throws ParseException{
    ReInit(new StringReader(cmd));
        ret = null;
    try {
        startInitCommand();
    } catch (ParseException e) {
        System.out.println("Exception during Parsing with Command:");
        System.out.println("  " + cmd +"\r\n"+ e);
     }
     return ii;
        }

        /**
	 * Method for parsing heared messages of the type:
	 * - Reconnect-Message
	 * @param - the message
	 * @return the corrpesonding info-object.
	 */
  public Info parseReconnect(String cmd)
      throws ParseException{
    ReInit(new StringReader(cmd));
        ret = null;

    try {
        startReconnect();
    } catch (ParseException e) {
        System.out.println("Exception during Parsing with Command:");
        System.out.println("  " + cmd +"\r\n"+ e);
    }
    return ret;
  }

  final public String quotedString() throws ParseException {
        Token tmp;
    tmp = jj_consume_token(STRING);
                 {if (true) return tmp.image;}
    throw new Error("Missing return statement in function");
  }

  final public String miscString() throws ParseException {
        StringBuffer buf = new StringBuffer();
        Token tmp;
    label_1:
    while (true) {
      switch (jj_nt.kind) {
      case SEP:
      case QM:
      case OB:
      case CB:
      case NAM:
        ;
        break;
      default:
        jj_la1[0] = jj_gen;
        break label_1;
      }
      switch (jj_nt.kind) {
      case QM:
        tmp = jj_consume_token(QM);
        break;
      case OB:
        tmp = jj_consume_token(OB);
        break;
      case CB:
        tmp = jj_consume_token(CB);
        break;
      case SEP:
        tmp = jj_consume_token(SEP);
        break;
      case NAM:
        tmp = jj_consume_token(NAM);
        break;
      default:
        jj_la1[1] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
                                                          buf.append(tmp.image);
    }
    jj_consume_token(0);
         {if (true) return buf.toString();}
    throw new Error("Missing return statement in function");
  }

  final public void startHearCommand() throws ParseException {
        Token cycle; Token dir; Token num=null;
        double dDir=0; String sMsg = new String("");
        boolean our = false; int number = -1;
    cycle = jj_consume_token(NUM);
    jj_consume_token(SEP);
    switch (jj_nt.kind) {
    case SELF:
      jj_consume_token(SELF);
      break;
    case REFEREE:
      jj_consume_token(REFEREE);
      jj_consume_token(SEP);
      hearReferee(cycle);
      break;
    case OLCOACHL:
      jj_consume_token(OLCOACHL);
                            ret = cl.parseCoach(cmd);
      break;
    case OLCOACHR:
      jj_consume_token(OLCOACHR);
                            ret = cl.parseCoach(cmd);
      break;
    case COACH:
      jj_consume_token(COACH);
      jj_consume_token(SEP);
      sMsg = quotedString();
                                int iCycle = Integer.parseInt(cycle.image);
                                CoachSayInfo csi = new CoachSayInfo(iCycle);
                        csi.setMessageType(MESSAGETYPE.FREEFORM);
                        csi.setFreeformMessage(sMsg);
                                ret = csi;
      break;
    case NUM:
      dir = jj_consume_token(NUM);
      jj_consume_token(SEP);
      switch (jj_nt.kind) {
      case OPP:
        jj_consume_token(OPP);
        jj_consume_token(SEP);
        quotedString();
        switch (jj_nt.kind) {
        case SEP:
          jj_consume_token(SEP);
          jj_consume_token(GOALIE);
          break;
        default:
          jj_la1[2] = jj_gen;
          ;
        }
        break;
      case OUR:
        jj_consume_token(OUR);
                                                        our = true;
        jj_consume_token(SEP);
        num = jj_consume_token(NUM);
                                                            number = Integer.parseInt(num.image);
        jj_consume_token(SEP);
        sMsg = quotedString();
        switch (jj_nt.kind) {
        case SEP:
          jj_consume_token(SEP);
          jj_consume_token(GOALIE);
          break;
        default:
          jj_la1[3] = jj_gen;
          ;
        }
                                                        // sMsg = msg.image;
                                                        dDir = Double.parseDouble(dir.image);
                                                        iCycle = Integer.parseInt(cycle.image);

                                                        psi.setCycle(iCycle);
                                                        psi.setDirection(dDir);
                                                        psi.setMessage(sMsg);
                                                        psi.setOur(our);
                                                        psi.setNumber(number);
                                                        ret = psi;
        break;
      default:
        jj_la1[4] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
      break;
    default:
      jj_la1[5] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

  final public void hearReferee(Token cycle) throws ParseException {
        PLAY_MODE playMode=PLAY_MODE.UNKNOWN;
        REFEREE_MESSAGE refereeMessage= REFEREE_MESSAGE.UNKNOWN;
        int iCycle;
    switch (jj_nt.kind) {
    case BEFORE_KICK_OFF:
    case TIME_OVER:
    case KICK_OFF_L:
    case KICK_OFF_R:
    case KICK_IN_L:
    case KICK_IN_R:
    case CORNER_KICK_R:
    case CORNER_KICK_L:
    case GOAL_KICK_R:
    case GOAL_KICK_L:
    case FREE_KICK_R:
    case FREE_KICK_L:
    case INDIRECT_FREE_KICK_L:
    case INDIRECT_FREE_KICK_R:
    case PLAY_ON:
    case GOAL_R:
    case GOAL_L:
    case PENALTY_SETUP_L:
    case PENALTY_SETUP_R:
    case PENALTY_READY_L:
    case PENALTY_READY_R:
    case PENALTY_TAKEN_L:
    case PENALTY_TAKEN_R:
    case PENALTY_MISS_L:
    case PENALTY_MISS_R:
    case PENALTY_SCORE_L:
    case PENALTY_SCORE_R:
    case PENALTY_WINNER_L:
    case PENALTY_WINNER_R:
      playMode = playMode();
        iCycle = Integer.parseInt(cycle.image);
        pmi.setCycle(iCycle);
        pmi.setPlayModeType(playMode);
    ret = pmi;
      break;
    case FREE_KICK_FAULT_L:
    case FREE_KICK_FAULT_R:
    case BACKPASS_L:
    case BACKPASS_R:
    case OFFSIDE_R:
    case OFFSIDE_L:
    case HALF_TIME:
    case TIME_UP:
    case TIME_UP_WITHOUT_A_TEAM:
    case TIME_EXTENDED:
    case FOUL_R:
    case FOUL_L:
    case DROP_BALL:
    case GOALIE_CATCH_BALL_L:
    case GOALIE_CATCH_BALL_R:
    case PENALTY_FOUL_L:
    case PENALTY_FOUL_R:
    case PENALTY_ONFIELD_L:
    case PENALTY_ONFIELD_R:
    case CATCH_FAULT_L:
    case CATCH_FAULT_R:
      refereeMessage = refereeMessage();
        iCycle = Integer.parseInt(cycle.image);
        ri.setCycle(iCycle);
        ri.setRefereeMessageType(refereeMessage);
    ret = ri;
      break;
    case NAM:
    case STRING:
      switch (jj_nt.kind) {
      case STRING:
        jj_consume_token(STRING);
        break;
      case NAM:
        jj_consume_token(NAM);
        break;
      default:
        jj_la1[6] = jj_gen;
        jj_consume_token(-1);
        throw new ParseException();
      }
    ret = null;
      break;
    default:
      jj_la1[7] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

  final public void startInitCommand() throws ParseException {
        Token side=null;
        PLAY_MODE playMode=PLAY_MODE.UNKNOWN;
        Token num;
    switch (jj_nt.kind) {
    case LEFT:
      side = jj_consume_token(LEFT);
      break;
    case RIGHT:
      side = jj_consume_token(RIGHT);
      break;
    default:
      jj_la1[8] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
        ra.setTeamEast(side.image.charAt(0) == 'r');
    jj_consume_token(SEP);
    num = jj_consume_token(NUM);
        ((RobocupAgent)ra).setNumber(Integer.parseInt(num.image));
    jj_consume_token(SEP);
    playMode = playMode();
        // TODO: set player init
        ii.setCycle(0);
        ii.setNumber(Integer.parseInt(num.image));
        ret = ii;
  }

  final public void startReconnect() throws ParseException {
    jj_consume_token(OB);
    jj_consume_token(CB);
  }

  final public PLAY_MODE playMode() throws ParseException {
    switch (jj_nt.kind) {
    case BEFORE_KICK_OFF:
      jj_consume_token(BEFORE_KICK_OFF);
    {if (true) return PLAY_MODE.BEFORE_KICK_OFF;}
      break;
    case TIME_OVER:
      jj_consume_token(TIME_OVER);
    {if (true) return PLAY_MODE.TIME_OVER;}
      break;
    case PLAY_ON:
      jj_consume_token(PLAY_ON);
    {if (true) return PLAY_MODE.PLAY_ON;}
      break;
    case KICK_OFF_L:
      jj_consume_token(KICK_OFF_L);
    if (ra.isTeamEast())
      {if (true) return PLAY_MODE.KICK_OFF_OTHER;}
    else
      {if (true) return PLAY_MODE.KICK_OFF_OWN;}
      break;
    case KICK_OFF_R:
      jj_consume_token(KICK_OFF_R);
    if (!ra.isTeamEast())
      {if (true) return PLAY_MODE.KICK_OFF_OTHER;}
    else
      {if (true) return PLAY_MODE.KICK_OFF_OWN;}
      break;
    case KICK_IN_L:
      jj_consume_token(KICK_IN_L);
    if (ra.isTeamEast())
      {if (true) return PLAY_MODE.KICK_IN_OTHER;}
    else
      {if (true) return PLAY_MODE.KICK_IN_OWN;}
      break;
    case KICK_IN_R:
      jj_consume_token(KICK_IN_R);
    if (!ra.isTeamEast())
      {if (true) return PLAY_MODE.KICK_IN_OTHER;}
    else
      {if (true) return PLAY_MODE.KICK_IN_OWN;}
      break;
    case FREE_KICK_L:
      jj_consume_token(FREE_KICK_L);
    if (ra.isTeamEast())
      {if (true) return PLAY_MODE.FREE_KICK_OTHER;}
    else
      {if (true) return PLAY_MODE.FREE_KICK_OWN;}
      break;
    case FREE_KICK_R:
      jj_consume_token(FREE_KICK_R);
    if (!ra.isTeamEast())
      {if (true) return PLAY_MODE.FREE_KICK_OTHER;}
    else
      {if (true) return PLAY_MODE.FREE_KICK_OWN;}
      break;
    case INDIRECT_FREE_KICK_L:
      jj_consume_token(INDIRECT_FREE_KICK_L);
    if (ra.isTeamEast())
      {if (true) return PLAY_MODE.INDIRECT_FREE_KICK_OTHER;}
    else
      {if (true) return PLAY_MODE.INDIRECT_FREE_KICK_OWN;}
      break;
    case INDIRECT_FREE_KICK_R:
      jj_consume_token(INDIRECT_FREE_KICK_R);
    if (!ra.isTeamEast())
      {if (true) return PLAY_MODE.INDIRECT_FREE_KICK_OTHER;}
    else
      {if (true) return PLAY_MODE.INDIRECT_FREE_KICK_OWN;}
      break;
    case CORNER_KICK_L:
      jj_consume_token(CORNER_KICK_L);
    if (ra.isTeamEast())
      {if (true) return PLAY_MODE.CORNER_KICK_OTHER;}
    else
      {if (true) return PLAY_MODE.CORNER_KICK_OWN;}
      break;
    case CORNER_KICK_R:
      jj_consume_token(CORNER_KICK_R);
    if (!ra.isTeamEast())
      {if (true) return PLAY_MODE.CORNER_KICK_OTHER;}
    else
      {if (true) return PLAY_MODE.CORNER_KICK_OWN;}
      break;
    case GOAL_KICK_L:
      jj_consume_token(GOAL_KICK_L);
    if (ra.isTeamEast())
      {if (true) return PLAY_MODE.GOAL_KICK_OTHER;}
    else
      {if (true) return PLAY_MODE.GOAL_KICK_OWN;}
      break;
    case GOAL_KICK_R:
      jj_consume_token(GOAL_KICK_R);
    if (!ra.isTeamEast())
      {if (true) return PLAY_MODE.GOAL_KICK_OTHER;}
    else
      {if (true) return PLAY_MODE.GOAL_KICK_OWN;}
      break;
    case GOAL_L:
      jj_consume_token(GOAL_L);
    if (ra.isTeamEast())
      {if (true) return PLAY_MODE.GOAL_OTHER;}
    else
      {if (true) return PLAY_MODE.GOAL_OWN;}
      break;
    case GOAL_R:
      jj_consume_token(GOAL_R);
    if (!ra.isTeamEast())
      {if (true) return PLAY_MODE.GOAL_OTHER;}
    else
      {if (true) return PLAY_MODE.GOAL_OWN;}
      break;
    case PENALTY_SETUP_L:
      jj_consume_token(PENALTY_SETUP_L);
                if (ra.isTeamEast())
                        {if (true) return PLAY_MODE.PENALTY_SETUP_OTHER;}
                else
                        {if (true) return PLAY_MODE.PENALTY_SETUP_OWN;}
      break;
    case PENALTY_SETUP_R:
      jj_consume_token(PENALTY_SETUP_R);
                if (!ra.isTeamEast())
                        {if (true) return PLAY_MODE.PENALTY_SETUP_OTHER;}
                else
                        {if (true) return PLAY_MODE.PENALTY_SETUP_OWN;}
      break;
    case PENALTY_READY_L:
      jj_consume_token(PENALTY_READY_L);
                if (ra.isTeamEast())
                        {if (true) return PLAY_MODE.PENALTY_READY_OTHER;}
                else
                        {if (true) return PLAY_MODE.PENALTY_READY_OWN;}
      break;
    case PENALTY_READY_R:
      jj_consume_token(PENALTY_READY_R);
                if (!ra.isTeamEast())
                        {if (true) return PLAY_MODE.PENALTY_READY_OTHER;}
                else
                        {if (true) return PLAY_MODE.PENALTY_READY_OWN;}
      break;
    case PENALTY_MISS_L:
      jj_consume_token(PENALTY_MISS_L);
                if (ra.isTeamEast())
                        {if (true) return PLAY_MODE.PENALTY_MISS_OTHER;}
                else
                        {if (true) return PLAY_MODE.PENALTY_MISS_OWN;}
      break;
    case PENALTY_MISS_R:
      jj_consume_token(PENALTY_MISS_R);
                if (!ra.isTeamEast())
                        {if (true) return PLAY_MODE.PENALTY_MISS_OTHER;}
                else
                        {if (true) return PLAY_MODE.PENALTY_MISS_OWN;}
      break;
    case PENALTY_SCORE_L:
      jj_consume_token(PENALTY_SCORE_L);
                if(ra.isTeamEast())
                        {if (true) return PLAY_MODE.PENALTY_SCORE_OTHER;}
                else
                        {if (true) return PLAY_MODE.PENALTY_SCORE_OWN;}
      break;
    case PENALTY_SCORE_R:
      jj_consume_token(PENALTY_SCORE_R);
                if(!ra.isTeamEast())
                        {if (true) return PLAY_MODE.PENALTY_SCORE_OTHER;}
                else
                        {if (true) return PLAY_MODE.PENALTY_SCORE_OWN;}
      break;
    case PENALTY_WINNER_L:
      jj_consume_token(PENALTY_WINNER_L);
                if(ra.isTeamEast())
                        {if (true) return PLAY_MODE.PENALTY_WINNER_OTHER;}
                else
                        {if (true) return PLAY_MODE.PENALTY_WINNER_OWN;}
      break;
    case PENALTY_WINNER_R:
      jj_consume_token(PENALTY_WINNER_R);
                if(!ra.isTeamEast())
                        {if (true) return PLAY_MODE.PENALTY_WINNER_OTHER;}
                else
                        {if (true) return PLAY_MODE.PENALTY_WINNER_OWN;}
      break;
    case PENALTY_TAKEN_L:
      jj_consume_token(PENALTY_TAKEN_L);
                if(ra.isTeamEast())
                        {if (true) return PLAY_MODE.PENALTY_TAKEN_OTHER;}
                else
                        {if (true) return PLAY_MODE.PENALTY_TAKEN_OWN;}
      break;
    case PENALTY_TAKEN_R:
      jj_consume_token(PENALTY_TAKEN_R);
                if(!ra.isTeamEast())
                        {if (true) return PLAY_MODE.PENALTY_TAKEN_OTHER;}
                else
                        {if (true) return PLAY_MODE.PENALTY_TAKEN_OWN;}
      break;
    default:
      jj_la1[9] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    throw new Error("Missing return statement in function");
  }

  final public REFEREE_MESSAGE refereeMessage() throws ParseException {
    switch (jj_nt.kind) {
    case OFFSIDE_R:
      jj_consume_token(OFFSIDE_R);
    if (!ra.isTeamEast())
      {if (true) return REFEREE_MESSAGE.OFFSIDE_OTHER;}
    else
      {if (true) return REFEREE_MESSAGE.OFFSIDE_OWN;}
      break;
    case OFFSIDE_L:
      jj_consume_token(OFFSIDE_L);
    if (ra.isTeamEast())
      {if (true) return REFEREE_MESSAGE.OFFSIDE_OTHER;}
    else
      {if (true) return REFEREE_MESSAGE.OFFSIDE_OWN;}
      break;
    case FOUL_R:
      jj_consume_token(FOUL_R);
    if (!ra.isTeamEast())
      {if (true) return REFEREE_MESSAGE.FOUL_OTHER;}
    else
      {if (true) return REFEREE_MESSAGE.FOUL_OWN;}
      break;
    case FOUL_L:
      jj_consume_token(FOUL_L);
    if (ra.isTeamEast())
      {if (true) return REFEREE_MESSAGE.FOUL_OTHER;}
    else
      {if (true) return REFEREE_MESSAGE.FOUL_OWN;}
      break;
    case GOALIE_CATCH_BALL_L:
      jj_consume_token(GOALIE_CATCH_BALL_L);
    if (ra.isTeamEast())
      {if (true) return REFEREE_MESSAGE.GOALIE_CATCH_BALL_OTHER;}
    else
      {if (true) return REFEREE_MESSAGE.GOALIE_CATCH_BALL_OWN;}
      break;
    case GOALIE_CATCH_BALL_R:
      jj_consume_token(GOALIE_CATCH_BALL_R);
    if (!ra.isTeamEast())
      {if (true) return REFEREE_MESSAGE.GOALIE_CATCH_BALL_OTHER;}
    else
      {if (true) return REFEREE_MESSAGE.GOALIE_CATCH_BALL_OWN;}
      break;
    case HALF_TIME:
      jj_consume_token(HALF_TIME);
      {if (true) return REFEREE_MESSAGE.HALF_TIME;}
      break;
    case DROP_BALL:
      jj_consume_token(DROP_BALL);
      {if (true) return REFEREE_MESSAGE.DROP_BALL;}
      break;
    case TIME_UP:
      jj_consume_token(TIME_UP);
      {if (true) return REFEREE_MESSAGE.TIME_UP;}
      break;
    case TIME_UP_WITHOUT_A_TEAM:
      jj_consume_token(TIME_UP_WITHOUT_A_TEAM);
      {if (true) return REFEREE_MESSAGE.TIME_UP_WITHOUT_A_TEAM;}
      break;
    case TIME_EXTENDED:
      jj_consume_token(TIME_EXTENDED);
      {if (true) return REFEREE_MESSAGE.TIME_EXTENDED;}
      break;
    case PENALTY_FOUL_L:
      jj_consume_token(PENALTY_FOUL_L);
                if (ra.isTeamEast())
                        {if (true) return REFEREE_MESSAGE.PENALTY_FOUL_OTHER;}
                else
                        {if (true) return REFEREE_MESSAGE.PENALTY_FOUL_OWN;}
      break;
    case PENALTY_FOUL_R:
      jj_consume_token(PENALTY_FOUL_R);
                if (!ra.isTeamEast())
                        {if (true) return REFEREE_MESSAGE.PENALTY_FOUL_OTHER;}
                else
                        {if (true) return REFEREE_MESSAGE.PENALTY_FOUL_OWN;}
      break;
    case FREE_KICK_FAULT_L:
      jj_consume_token(FREE_KICK_FAULT_L);
                if (ra.isTeamEast())
                        {if (true) return REFEREE_MESSAGE.FREE_KICK_FAULT_OTHER;}
                else
                        {if (true) return REFEREE_MESSAGE.FREE_KICK_FAULT_OWN;}
      break;
    case FREE_KICK_FAULT_R:
      jj_consume_token(FREE_KICK_FAULT_R);
                if (!ra.isTeamEast())
                        {if (true) return REFEREE_MESSAGE.FREE_KICK_FAULT_OTHER;}
                else
                        {if (true) return REFEREE_MESSAGE.FREE_KICK_FAULT_OWN;}
      break;
    case CATCH_FAULT_L:
      jj_consume_token(CATCH_FAULT_L);
                if (ra.isTeamEast())
                        {if (true) return REFEREE_MESSAGE.CATCH_FAULT_OTHER;}
                else
                        {if (true) return REFEREE_MESSAGE.CATCH_FAULT_OWN;}
      break;
    case CATCH_FAULT_R:
      jj_consume_token(CATCH_FAULT_R);
                if (!ra.isTeamEast())
                        {if (true) return REFEREE_MESSAGE.CATCH_FAULT_OTHER;}
                else
                        {if (true) return REFEREE_MESSAGE.CATCH_FAULT_OWN;}
      break;
    case PENALTY_ONFIELD_L:
      jj_consume_token(PENALTY_ONFIELD_L);
                if (ra.isTeamEast())
                        {if (true) return REFEREE_MESSAGE.PENALTY_ON_FIELD_OTHER;}
                else
                        {if (true) return REFEREE_MESSAGE.PENALTY_ON_FIELD_OWN;}
      break;
    case PENALTY_ONFIELD_R:
      jj_consume_token(PENALTY_ONFIELD_R);
        if (!ra.isTeamEast())
                {if (true) return REFEREE_MESSAGE.PENALTY_ON_FIELD_OTHER;}
                else
                        {if (true) return REFEREE_MESSAGE.PENALTY_ON_FIELD_OWN;}
      break;
    case BACKPASS_L:
      jj_consume_token(BACKPASS_L);
                if (ra.isTeamEast())
                        {if (true) return REFEREE_MESSAGE.BACKPASS_OTHER;}
                else
                        {if (true) return REFEREE_MESSAGE.BACKPASS_OWN;}
      break;
    case BACKPASS_R:
      jj_consume_token(BACKPASS_R);
                if (!ra.isTeamEast())
                        {if (true) return REFEREE_MESSAGE.BACKPASS_OTHER;}
                else
                        {if (true) return REFEREE_MESSAGE.BACKPASS_OWN;}
      break;
    default:
      jj_la1[10] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    throw new Error("Missing return statement in function");
  }

  public HearParserTokenManager token_source;
  SimpleCharStream jj_input_stream;
  public Token token, jj_nt;
  private int jj_gen;
  final private int[] jj_la1 = new int[11];
  static private int[] jj_la1_0;
  static private int[] jj_la1_1;
  static private int[] jj_la1_2;
  static {
      jj_la1_0();
      jj_la1_1();
      jj_la1_2();
   }
   private static void jj_la1_0() {
      jj_la1_0 = new int[] {0x0,0x0,0x0,0x0,0xc0,0x3e00,0x0,0xffffc000,0x30,0xfffc000,0xf0000000,};
   }
   private static void jj_la1_1() {
      jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xfffffff9,0x0,0xc3ff1801,0x3c00e7f8,};
   }
   private static void jj_la1_2() {
      jj_la1_2 = new int[] {0x1d8,0x1d8,0x8,0x8,0x0,0x20,0x300,0x306,0x0,0x0,0x6,};
   }

  public HearParser(java.io.InputStream stream) {
     this(stream, null);
  }
  public HearParser(java.io.InputStream stream, String encoding) {
    try { jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
    token_source = new HearParserTokenManager(jj_input_stream);
    token = new Token();
    token.next = jj_nt = token_source.getNextToken();
    jj_gen = 0;
    for (int i = 0; i < 11; i++) jj_la1[i] = -1;
  }

  public void ReInit(java.io.InputStream stream) {
     ReInit(stream);
  }
  public void ReInit(java.io.InputStream stream, String encoding) {
    try { jj_input_stream.ReInit(stream, encoding, 1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new RuntimeException(e); }
    token_source.ReInit(jj_input_stream);
    token = new Token();
    token.next = jj_nt = token_source.getNextToken();
    jj_gen = 0;
    for (int i = 0; i < 11; i++) jj_la1[i] = -1;
  }

  public HearParser(java.io.Reader stream) {
    jj_input_stream = new SimpleCharStream(stream, 1, 1);
    token_source = new HearParserTokenManager(jj_input_stream);
    token = new Token();
    token.next = jj_nt = token_source.getNextToken();
    jj_gen = 0;
    for (int i = 0; i < 11; i++) jj_la1[i] = -1;
  }

  public void ReInit(java.io.Reader stream) {
    jj_input_stream.ReInit(stream, 1, 1);
    token_source.ReInit(jj_input_stream);
    token = new Token();
    token.next = jj_nt = token_source.getNextToken();
    jj_gen = 0;
    for (int i = 0; i < 11; i++) jj_la1[i] = -1;
  }

  public HearParser(HearParserTokenManager tm) {
    token_source = tm;
    token = new Token();
    token.next = jj_nt = token_source.getNextToken();
    jj_gen = 0;
    for (int i = 0; i < 11; i++) jj_la1[i] = -1;
  }

  public void ReInit(HearParserTokenManager tm) {
    token_source = tm;
    token = new Token();
    token.next = jj_nt = token_source.getNextToken();
    jj_gen = 0;
    for (int i = 0; i < 11; i++) jj_la1[i] = -1;
  }

  final private Token jj_consume_token(int kind) throws ParseException {
    Token oldToken = token;
    if ((token = jj_nt).next != null) jj_nt = jj_nt.next;
    else jj_nt = jj_nt.next = token_source.getNextToken();
    if (token.kind == kind) {
      jj_gen++;
      return token;
    }
    jj_nt = token;
    token = oldToken;
    jj_kind = kind;
    throw generateParseException();
  }

  final public Token getNextToken() {
    if ((token = jj_nt).next != null) jj_nt = jj_nt.next;
    else jj_nt = jj_nt.next = token_source.getNextToken();
    jj_gen++;
    return token;
  }

  final public Token getToken(int index) {
    Token t = token;
    for (int i = 0; i < index; i++) {
      if (t.next != null) t = t.next;
      else t = t.next = token_source.getNextToken();
    }
    return t;
  }

  private java.util.Vector jj_expentries = new java.util.Vector();
  private int[] jj_expentry;
  private int jj_kind = -1;

  public ParseException generateParseException() {
    jj_expentries.removeAllElements();
    boolean[] la1tokens = new boolean[74];
    for (int i = 0; i < 74; i++) {
      la1tokens[i] = false;
    }
    if (jj_kind >= 0) {
      la1tokens[jj_kind] = true;
      jj_kind = -1;
    }
    for (int i = 0; i < 11; i++) {
      if (jj_la1[i] == jj_gen) {
        for (int j = 0; j < 32; j++) {
          if ((jj_la1_0[i] & (1<<j)) != 0) {
            la1tokens[j] = true;
          }
          if ((jj_la1_1[i] & (1<<j)) != 0) {
            la1tokens[32+j] = true;
          }
          if ((jj_la1_2[i] & (1<<j)) != 0) {
            la1tokens[64+j] = true;
          }
        }
      }
    }
    for (int i = 0; i < 74; i++) {
      if (la1tokens[i]) {
        jj_expentry = new int[1];
        jj_expentry[0] = i;
        jj_expentries.addElement(jj_expentry);
      }
    }
    int[][] exptokseq = new int[jj_expentries.size()][];
    for (int i = 0; i < jj_expentries.size(); i++) {
      exptokseq[i] = (int[])jj_expentries.elementAt(i);
    }
    return new ParseException(token, exptokseq, tokenImage);
  }

  final public void enable_tracing() {
  }

  final public void disable_tracing() {
  }

}
